package com.atmaowei.controller;

import com.atmaowei.common.Result;
import com.atmaowei.controller.request.SctPageRequest;
import com.atmaowei.entity.Department;
import com.atmaowei.entity.Sct;
import com.atmaowei.service.SctService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/sct")
public class SctController {

    @Autowired
    private SctService sctService;

    @DeleteMapping("/delete/{sno}/{cno}/{tno}")
    public Result delete(@PathVariable String sno,@PathVariable String cno,@PathVariable String tno) {
        sctService.delete(sno,cno,tno);
        return Result.success();
    }

    @GetMapping("/page")
    public Result page(SctPageRequest sctPageRequest) {
        return Result.success(sctService.page(sctPageRequest));
    }

    @PostMapping("/deleteSelected")
    public Result deleteSelected(@RequestBody List<Sct> scts) {
        sctService.deleteSelected(scts);
        return Result.success();
    }
}
